<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>回调refs中回调执行次数的问题</title>
</head>
<body>
     <!-- 引入React核心库 -->
     <script src="../JS/react.development.js"></script>
     <!-- 引入ReactDOM，用于支持react操作DOM -->
     <script src="../JS/react-dom.development.js"></script>
     <!-- 引入babel 用于将书写的JSX语法 编译成JS语法 -->
     <script src="../JS/babel.min.js"></script>

    <div id="test"></div>

    <script type="text/babel">  
        class Demo extends React.Component{
            showData=()=>{
                const {input1} = this
                alert(input1.value)
            }
            changeWeather=()=>{
                const {isHot} = this.state
                this.setState({
                    isHot : !isHot
                })
            }
            state={
                isHot:true
            }
            saveInput=(c)=>{
                this.input1 = c
                console.log(c);
            }
            render(){
                const {isHot} = this.state
                return(
                    <div>
                        {/*<input ref={c=>{this.input1 = c;console.log('@',c)}} type="text"/>*/} 
                        <input ref={this.saveInput} type="text"/>
                        <button onClick={this.showData}>点我提示输入的数据</button>
                        <hr/>
                        <h6>今天天气很{isHot?'炎热':'凉爽'}</h6>
                        <button onClick={this.changeWeather}>点我切换天气</button>
                    </div>
                )
            }
        }
        ReactDOM.render(<Demo />,document.getElementById('test'))



        /* 
            总结陈词 
                无关紧要 还是写 内联 
                该写法 只 针对某些较真狗
        */

    </script>







</body>
</html>